<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 全选，不选，反选 -->
    <button id="btn1"> 全选：</button>
    <button id="btn2"> 不选：</button>
    <button id="btn3"> 反选：</button>
    <br>
    <table id="tabl">
        <input type="checkbox" checked>
        <input type="checkbox">
        <input type="checkbox">
        <input type="checkbox">
        <input type="checkbox">
        <input type="checkbox">
        <input type="checkbox">
    </table>
    <script>
        var btn1 = document.getElementById("btn1")
        var btn2 = document.getElementById("btn2")
        var btn3 = document.getElementById("btn3")
        var inp = document.getElementsByTagName('input')
        window.onload = function () {
            btn1.onclick = function () {
                for (var i = 0; i < inp.length; i++) {
                    inp[i].checked = "cheked"
                }
            }
            btn2.onclick = function () {
                for (var i = 0; i < inp.length; i++) {
                    inp[i].checked = ""
                }
            }
            btn3.onclick = function () {
                for (var i = 0; i < inp.length; i++) {
                    inp[i].checked == "" ? inp[i].checked = "checked" : inp[i].checked = ""
                }
            }
        }
    </script>

</body>

</html>